home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8928 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: access4.digex.net!not-for-mail
  2. From: ell@access4.digex.net (Ell)
  3. Newsgroups: comp.object,comp.lang.c++
  4. Subject: Re: A design question
  5. Date: 27 Feb 1996 14:07:32 GMT
  6. Organization: The Universe
  7. Message-ID: <4gv374$g54@news4.digex.net>
  8. References: <1996Feb22.234825.18755@dcs.warwick.ac.uk> <4gu4br$bmc@news4.digex.net>
  9. NNTP-Posting-Host: access4.digex.net
  10. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  11.  
  12. Ell (ell@access1.digex.net) wrote:
  13. : Robert Marrtin writes:
  14. : : class ParcelState
  15. : : {
  16. : :   public:
  17. : :     // the events that occur along the processing chain.
  18. : :     virtual void Event1(MyParcel&) = 0;
  19. : :     virtual void Event2(MyParcel&) = 0;
  20. : : };
  21. : : 
  22. : : // This is the parcel itself.  It also defines functions which respond
  23. : : // to all its events.  However, these functions simply delegate to the
  24. : : // contained state object.
  25. : : 
  26. : : class MyParcel
  27. : : {
  28. : :   public:
  29. : :     MyParcel();
  30. : :     void Event1() {itsState->Event1(*this);}
  31. : :     void Event2() {itsState->Event2(*this);}
  32. : :   private:
  33. : :     ParcelState* itsState;
  34. : : };
  35.  
  36. : I'm wondering if the above class MyParcel shouldn't publicly inherit from 
  37. : ParcelState?
  38.  
  39. I see now, that no you don't want such inheritance.  You want to call the 
  40. methods of the children of ParcelState in MyParcel's methods.
  41.  
  42. Elliott
  43.